home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1995 May / cd Ware (Juegos) Epimundo.iso / DOS / C / BTRVEX.ZIP / ASTATE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-04-11  |  1012 b   |  46 lines

  1. #include <btrvexp.h>
  2. #include <stdio.h>
  3. #include <conio.h>
  4. #include <string.h>
  5.  
  6. main()
  7. {
  8.    struct
  9.       {
  10.       char state[15];
  11.       char areacode[3];
  12.       char abbrev[2];
  13.       } record;
  14.  
  15.    char inbuf[6];
  16.  
  17.    BSTART();
  18.    while (TRUE)
  19.       {
  20.       inbuf[0] = 3;
  21.       inbuf[1] = 0;
  22.       printf("\n\nEnter a two-letter State Code: ");
  23.       cgets(inbuf);
  24.  
  25.       if (inbuf[1] == 0)
  26.          {
  27.          printf("\n");
  28.          BCLOSE(ALL_FILES);
  29.          exit(0);
  30.          }
  31.  
  32.       BGET(B_GE,"areacode.dat",2,&record,&inbuf[2]);
  33.       if (BSTATUS == 0 && (strnicmp(record.abbrev,&inbuf[2],2) == 0) )
  34.          {
  35.          printf("\n\nArea Codes for %.15s\n",record.state);
  36.          while (BSTATUS == 0 && (strnicmp(record.abbrev,&inbuf[2],2) == 0) )
  37.             {
  38.             printf("%.3s  ",record.areacode);
  39.             BGET(B_NEXT,"areacode.dat",2,&record,NULL);
  40.             }
  41.          }
  42.       else
  43.          printf("\n That is not a valid State Code");
  44.       }
  45. }
  46.